package com.software.graduationproject.modules.food.web;

import com.baomidou.mybatisplus.core.metadata.Page;

import com.software.graduationproject.commons.select.Select;
import com.software.graduationproject.commons.util.Result;
import com.software.graduationproject.commons.util.Results;
import com.software.graduationproject.modules.food.entity.FoodType;
import com.software.graduationproject.modules.food.object.FoodTypeVo;
import com.software.graduationproject.modules.food.service.FoodTypeService;
import com.software.graduationproject.modules.food.object.FoodTypeCreateQo;
import com.software.graduationproject.modules.food.object.FoodTypeUpdateQo;

import com.v2coding.validate.CreateGroup;
import com.v2coding.validate.UpdateGroup;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * FoodTypeController : 食品表
 * ---------------------------------------------------------------------------------------------------------------------
 */
@Validated
@RestController
@RequestMapping("/Food/FoodType")
@Api(value = "API - 食品表", tags = {"食品表接口"})
public class FoodTypeController {

    @Autowired
    private FoodTypeService foodTypeService;

    @PostMapping("/create")
    @ApiOperation("新增食品表")
    public Result createQo(@RequestBody @Validated(CreateGroup.class) FoodTypeCreateQo qo) {
        foodTypeService.createQo(qo);
        return Results.success();
    }
//
//    @PostMapping("/update")
//    @ApiOperation("修改食品表")
//    public Result updateQo(@RequestBody @Validated(UpdateGroup.class) FoodTypeUpdateQo qo) {
//        foodTypeService.updateQo(qo);
//        return Results.success();
//    }
//
//    @PostMapping("/delete")
//    @ApiOperation("删除食品表")
//    public Result delete(@RequestBody Long id) {
//        foodTypeService.delete(id);
//        return Results.success();
//    }
//
//    @PostMapping("/deleteList")
//    @ApiOperation("批量删除食品表")
//    public Result deleteList(@RequestBody Long []ids) {
//        foodTypeService.deleteList(ids);
//        return Results.success();
//    }
//
//    @GetMapping("/select")
//    @ApiOperation("查询食品表详情")
//    public Result<FoodTypeVo> selectVo(Long id) {
//        FoodTypeVo foodTypeVo = foodTypeService.selectVo(id);
//        return Results.success(foodTypeVo);
//    }

    @GetMapping("/selectList")
    @ApiOperation("查询食品表列表")
    @ApiImplicitParams({ //
            @ApiImplicitParam(name = "select", value = "查询条件", required = false, dataTypeClass = String.class, paramType = "query"),//
    })
    public Result<List<FoodTypeVo>> selectListVo(@ApiIgnore Select select) {
        List<FoodTypeVo> foodTypeVoList = foodTypeService.selectListVo(select);
        return Results.success(foodTypeVoList);
    }

    @GetMapping("/selectPage")
    @ApiOperation("查询食品表分页")
    @ApiImplicitParams({ //
            @ApiImplicitParam(name = "select", value = "查询条件", required = false, dataTypeClass = String.class, paramType = "query"),//
    })
    public Result<Page<FoodTypeVo>> selectPageVo(@ApiIgnore Select select) {
        Page<FoodTypeVo> foodTypeVoPage = foodTypeService.selectPageVo(select);
        return Results.success(foodTypeVoPage);
    }



}
